API Documentation for: 1.1.23
Show:

DragManager (CreateJS) Class

Namespace: cloudkid

Drag manager is responsible for handling the dragging of stage elements. Supports click-n-stick (click to start, move mouse, click to release) and click-n-drag (standard dragging) functionality.

Constructor

DragManager (CreateJS)

(
  • startCallback
  • endCallback
)

Parameters:

  • startCallback Function

    The callback when when starting

  • endCallback Function

    The callback when ending

Methods

_handlePointSnap

(
  • localMousePos
)
private

Handles snapping the dragged object to the nearest among a list of points

Parameters:

  • localMousePos createjs.Point

    The mouse position in the same space as the dragged object.

_objMouseDown

(
  • ev
  • object
)
private

Defined in _objMouseDown:213

Mouse down on an obmect

Parameters:

  • ev createjs.MouseEvent

    A mouse down event to listen to to determine what type of drag should be used.

  • object createjs.DisplayObject

    The object that should be dragged.

_startDrag

() private

Defined in _startDrag:301

Internal start dragging on the stage

_stopDrag

(
  • ev
  • doCallback
)
private

Defined in _stopDrag:328

Internal stop dragging on the stage

Parameters:

  • ev createjs.MouseEvent

    Mouse up event

  • doCallback Bool

    If we should do the callback

_triggerHeldDrag

(
  • ev
)
private

Start hold dragging

Parameters:

  • ev createjs.MouseEvent

    The mouse down event

_triggerStickyClick

() private

Start the sticky click

_updateObjPosition

(
  • e
)
private

Update the object position based on the mouse

Parameters:

  • e createjs.MouseEvent

    Mouse move event

addObject

(
  • obj
  • bound
)
public

Defined in addObject:451

Adds properties and functions to the object - use enableDrag() and disableDrag() on objects to enable/disable them (they start out disabled). Properties added to objects: _dragBounds (Rectangle), _onMouseDownListener (Function), _dragMan (cloudkid.DragManager) reference to the DragManager these will override any existing properties of the same name

Parameters:

  • obj createjs.DisplayObject

    The display object

  • bound createjs.Rectangle

    The rectangle bounds

destroy

() public

Defined in destroy:501

Destroy the manager

initialize

(
  • startCallback
  • endCallback
)

Defined in initialize:179

Constructor

Parameters:

  • startCallback Function

    The callback when when starting

  • endCallback Function

    The callback when ending

removeObject

(
  • obj
)
public

Defined in removeObject:482

Removes properties and functions added by addObject().

Parameters:

  • obj createjs.DisplayObject

    The display object

startDrag

(
  • object
  • ev
)
public

Defined in startDrag:200

Manually starts dragging an object. If a mouse down event is not supplied as the second argument, it defaults to a held drag, that ends as soon as the mouse is released.

Parameters:

  • object createjs.DisplayObject

    The object that should be dragged.

  • ev createjs.MouseEvent

    A mouse down event to listen to to determine what type of drag should be used.

stopDrag

(
  • doCallback
)
public

Defined in stopDrag:317

Stops dragging the currently dragged object.

Parameters:

  • doCallback Bool

    If the drag end callback should be called. Default is false.

Properties

_dragEndCallback

Function private

Callback when we are done dragging

_draggableObjects

Array private

The collection of draggable objects

_dragOffset

createjs.Point private

Defined in _dragOffset:116

The local to global position of the drag

_dragStartCallback

Function private

Callback when we start dragging

_helperPoint

createjs.Point private

Defined in _helperPoint:172

A point for reuse instead of lots of object creation.

_stageMouseUpCallback

Function private

Callback when we are done with the drag

_theStage

CreatejsStage private

Defined in _theStage:109

Reference to the stage

_triggerHeldDragCallback

Function private

Callback to test for the start a held drag

_triggerStickyClickCallback

Function private

Callback to start a sticky click drag

_updateCallback

Function private

Defined in _updateCallback:165

The function call when the mouse/touch moves

allowStickyClick

Bool public

Defined in allowStickyClick:55

If sticky click dragging is allowed.

Default: true

draggedObj

createjs.DisplayObject public

Defined in draggedObj:25

The object that's being dragged

dragStartThreshold

Unknown public

The radius in pixel to allow for dragging, or else does sticky click

Default: 20

isHeldDrag

Bool public

Defined in isHeldDrag:72

Is the drag being held on mouse down (not sticky clicking)

Default: false

isStickyClick

Bool public

Defined in isStickyClick:81

Is the drag a sticky clicking (click on a item, then mouse the mouse)

Default: false

isTouchMove

Bool public

Defined in isTouchMove:63

Is the move touch based

Default: false

mouseDownObjPos

Object private

Defined in mouseDownObjPos:48

The position x, y of the object when interaction with it started.

mouseDownStagePos

Object private

The position x, y of the mouse down on the stage

snapSettings

Object public

Defined in snapSettings:90

Settings for snapping.

Format for snapping to a list of points: { mode:"points", dist:20,//snap when within 20 pixels/units points:[ { x: 20, y:30 }, { x: 50, y:10 } ] }

Default: null